package com.mrkun.vueshop.mapper;

import com.mrkun.vueshop.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author by yong
 * @date 2020/3/15
 */
@Mapper
public interface UserMapper {

    @Select("select * from user where username like #{searchName}")
    List<User> findAllUser(@Param("searchName") String searchName);

    @Select("select * from user where id = #{id}")
    User findOne(@Param("id")Integer id);

    @Insert("insert into user (username,password,role,money) values (#{username},#{password},#{role},#{money})")
    void addUser(User user);

    @Select("select * from user where username = #{username} and password = #{password}")
    User login(@Param("username")String username,@Param("password") String password);

    @Select("select count(0) from user")
    Integer getCount();

    @Update("update user set username = #{username},password = #{password},money=#{money} where id = #{id}")
    void updateUser(User user);

    @Select("select * from user where username like #{searchName}")
    List<User> findOneByName(@Param("searchName")String searchName);

    @Delete("delete from user where id = #{id}")
    void deleteUserById(@Param("id")Integer id);

    @Select("select * from user where username = #{username}")
    User getOneByName(@Param("username")String username);
}
